// 1. 计算一致字符串
function fn1(allowed, words) {
    var n = 0;
    words.forEach(function (item) {
        var narr = item.split('');
        if (narr.every(function (item) { return allowed.indexOf(item) !== -1; })) {
            n++;
        }
    });
    return n;
}
console.log(fn1('abc', ['ab', 'ac', 'bc', 'abc', 'acd', 'aa']));
// 2. 获取url及封装深拷贝方法
function fn2(str2) {
    var newStr = [];
    newStr.push.apply(newStr, str2.split(''));
    for (var i = 0; i < newStr.length; i++) {
        if (typeof (Number(newStr[i]))) {
            console.log(newStr[i]);
        }
    }
}
// 3. 买卖股票的最佳时机
function gup(prices) {
    var pro = 0;
    for (var i = 0; i < prices.length; i++) {
        var tmp = prices[i] - prices[i - 1];
        if (tmp > 0) {
            pro += tmp;
        }
    }
    return pro;
}
console.log(gup([6, 2, 4, 3, 5, 1]));
// 4. 找只出现一次的元素
function fnc(nums) {
    var num = -1;
    for (var i = 0; i < nums.length; i++) {
        if (nums.indexOf(nums[i]) == nums.lastIndexOf(nums[i])) {
            num = nums[i];
        }
    }
    return num;
}
console.log(fnc([1, 2, 3, 2, 1, 4, 5]));
// 5. 多维转一纬
function flat(arr, k) {
    if (k === void 0) { k = 1; }
    var narr = [];
    arr.forEach(function (item) {
        if (Array.isArray(item) && k >= 1) {
            narr = narr.concat(flat(item, k - 1));
        }
        else {
            narr = narr.concat(item);
        }
    });
    return narr;
}
console.log(flat([1, [1, 2, 3, [1, 2, 3, 4, 5, 6]]]));
